<?php include './application/views/common/zhs_header.php';?>

<?php include './application/views/common/zhs_usercenter_acnt.php';?>
<div class="inv_box w">
<?php include './application/views/common/zhs_usercenter_left.php';?>
  <div class="membd_right">
     <h3 class="membdrg_tit">手机认证</h3>
    <div class="mem_perbox">
    	<form id="phone_form">
<input type="hidden" value="" name="act" id="act">
<?php if($user['phone_status'] == 1 ){ ?>
		<div class="user_right_border">
			<p>您的手机已经通过认证：<?php echo strdisplay($user['phone'], 4); ?>
			<a href="javascript:;" onclick="huanblock();"  style="color: #a71e32; text-decoration:underline;padding-left:120px;">绑定更换</a>
			</p>
		</div>
		
		<div id="phonehuan" style="display:none">
			<div class="user_right_border">
				<div style="float:left">
					<div class="emab"><span style="float:left">更换条件：</span>
					<input style="float:left; margin:0 4px;" type="radio" name="typer" value="oldphone" onclick="typerphone(this);" checked ><span style="float:left">旧手机验证</span>
					<input style="float:left; margin:0 4px;" type="radio" name="typer" value="paypw" onclick="typerphone(this);" ><span style="float:left">隐私信息</span>
					</div>
				</div>
			</div>
			<div id="oldphone" style="display:block">
				<div class="user_right_border">
					<div class="l">旧手机验证码：</div>
					<div class="c">
						<input type="text" value="" name="old_verify_code" maxlength="12">
						<span id="phone_code">
						<input type="button" value="获取验证码" onclick="peSubmit();">
						</span>
					</div>
				</div>
				
			</div>
			
			<div id="paypw" style="display:none">
				<div class="user_right_border">
					<div class="l">身份证号：</div>
					<div class="c">
						<input type="text" value="" name="cardid" id="cardid" maxlength="20">
					</div>
				</div>
				<div class="user_right_border">
					<div class="l">交易密码：</div>
					<div class="c">
						<input type="password" value="" name="paypassword" id="paypassword" >
					</div>
				</div>
			</div>
			<div class="user_right_border">
				<div class="l">新绑定手机号码：</div>
				<div class="c">
					<input type="text" value="" name="phone" id="phone" maxlength="11">
				</div>
			</div>
			<div class="user_right_border">
				<div class="l">新手机验证码：</div>
				<div class="c">
					<input type="text" value="" name="verify_code" maxlength="12">
					<span id="phone_code">
					<input type="button" value="获取验证码" onclick="phoneSubmit('apply');">
					</span>
				</div>
			</div>
			<input style="margin-left:112px; margin-top:30px;" type="button" value="提交更换" onclick="phoneSubmit('verify');">
		</div>
		
<?php }?>
		
</form>
     </div>
<script  type="text/javascript">
function huanblock(){
	var submenu=document.getElementById('phonehuan');
	submenu.style.display="block";
}
function typerphone(obj){
	var oldphone=document.getElementById('oldphone');
	var paypw=document.getElementById('paypw');
	if(obj.value == 'oldphone') {
		oldphone.style.display = 'block';
		paypw.style.display = 'none';
	}
	else if(obj.value  == 'paypw'){
		oldphone.style.display = 'none';
		paypw.style.display = 'block';
	}
}

function peSubmit(){
	$.ajax({
		type: "post",
		url: "/reg/sendsms.html",
		success: function(ret){
			if(ret.info == 1){
				phone_countdown();
			}else{
				$("#phone_code").html(ret.msg);
				setTimeout(function(){
				$("#phone_code").html('<a href="javascript:;" onclick="peSubmit();" style="color:#a71e32; text-decoration:underline"> 重新获取手机验证码</a>');
					
				},3000);
			}
		},
		dataType: "json"
	});	
}
function phone_countdown(){
	var count = 180;
	var countdown = setInterval(CountDown, 1000); 
	function CountDown() {
		$("#phone_code").html('手机验证码已发送,请等待 <font style="color:#a71e32;">'+count+"</font>秒");
		if (count == 0) {
			$("#phone_code").html('<a href="javascript:;" onclick="peSubmit();" style="color:#a71e32; text-decoration:underline"> 重新获取手机验证码</a>');
			clearInterval(countdown);
		}
		count--;
	}
}
function phoneSubmit(txt){
	$('#act').val(txt);
	var options = {
		url : GetUrlRelativePath(),
		//clearForm :true,
		//resetForm :true,
		beforeSubmit:  checkForm,
		dataType: "json",
		type:"post",
		success : function(ret) {
			$('#dialog').dialog({
				modal:true,
				title:'系统提示',
				buttons:{"确定":function(){$(this).dialog("close");}},
				close: function() {
					if(ret.url!=''){
						if(txt == 'verify')
							window.location=ret.url;
					}
				}
			}); 
			$("#msg").html(ret.msg);
		}
	};
	$("#phone_form").ajaxSubmit(options);
	return false;
}
function checkForm(){
	var err = '';
	if(IsPhone($('#phone').val())==false){
		err = '请填写有效的号码';
	}
	
	if(err==''){
		return true;
	}else{
		$('#dialog').dialog({
			modal:true, //蒙层（弹出会影响页面大小）
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}}
		}); 
		$("#msg").html(err);
		return false;
	}
}


</script>
   </div>
</div> 

<?php include './application/views/common/zhs_footer.php';?>
<?php include './application/views/common/zhs_right.php';?>
    